package com.lww.feature.test.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * author: liweiwei
 * Date: 2018/11/30
 */
public class MyInvocationHandler implements InvocationHandler {




    private Object target;
    public MyInvocationHandler(Object target) {
        this.target=target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Class<?> proxyClass = proxy.getClass();
        System.out.println("proxy is:" + proxyClass.getName());
        for (Method method1 : proxyClass.getMethods()) {
            System.out.println(method1.getName());
        }

        System.out.println("method :"+ method.getName()+" is invoked!");
        return method.invoke(target,args);
    }

}
